package com.isias.system.mapper;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.isias.model.dto.UserAndIdDto;
import com.isias.model.system.SysUser;
import com.isias.model.vo.SysUserQueryVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 用户表 Mapper 接口
 * </p>
 *
 * @author fanyi
 * @since 2023-02-19
 */
@Mapper
public interface SysUserMapper extends BaseMapper<SysUser> {

    IPage<SysUser> selectPage(Page<SysUser> page, @Param("vo") SysUserQueryVo sysUserQueryVo);

    Integer updataStatus(String id,Integer status);

    @Update("update sys_user set head_url=#{url} where username=#{username}")
    Boolean updataUrl(String username, String url);

    @Select("select * from sys_user where username=#{username} and is_deleted = 0")
    SysUser selectUser(String username);
    @Select("select * from sys_user where phone=#{phone} and is_deleted = 0")
    SysUser selectUserphone(String phone);
    @Select("select post_id from sys_user where id=#{userId} and is_deleted = 0")
    String getPost(String userId);

    @Update("update sys_user set post_id=#{postid} where id=#{id}")
    Integer updatePostId(String id, String postid);
    @Update("update sys_user set dept_id=#{deptId} where id=#{userId}")
    Integer updateDeptId(String userId, String deptId);

    @Select("select dept_id from sys_user where id=#{userId} and is_deleted = 0")
    String selectUserDept(String userId);

    @Select("select name,id from sys_user where status=1 and is_deleted = 0")
    List<UserAndIdDto> SelectUserAndId();

    @Select("select id from sys_user where username=#{username} and status=1 and is_deleted = 0")
    String GetIdByUsername(String username);

    @Update("update sys_user set password=#{password} where username=#{username}")
    Integer UpdatePassword(String username, String password);
}
